import { Component,ElementRef,OnInit,Input,ViewChild, Output, EventEmitter,AfterViewInit} from '@angular/core';
import { Http } from '@angular/http';
import { HttpClientModule, HttpClient, HttpErrorResponse } from '@angular/common/http';

import { Service } from '../../../server/server';
import { CudTableService } from '../../../public/serve/cud-table/cud-table.service';
import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
declare var $: any;

@Component({
  selector: 'app-task-delete',
  templateUrl: './task-delete.component.html'
})
export class TaskDeleteComponent implements OnInit {

  constructor(private server :Service,private tableListService:CudTableService,private removeTableService: RemoveTableService) { }

  ngOnInit() {
  }


  @Output()
  deleteOutput: EventEmitter<string> = new EventEmitter();

  delete(){
    let url = this.server.baseUrl+'admin/tasks/delete';
    this.removeTableService.confirmRemove("taskId", url).then((res: any) => {
      this.deleteOutput.emit(res.result_code);
      if (res.result_code == '0000') {
        this.server.prompt = { prompt: true, success: true, fail: false, promptStatement: res.message }
        this.server.promptclose;
        $("#delete").modal("hide");
      } else {
        this.server.prompt = { prompt: true, success: false, fail: true, promptStatement: res.message }
        this.server.promptclose;
      }
    }).catch()
  }
}